<?php
    
    class Admin extends Core{
    	
		public function __construct(){
			parent::__construct();
			
		}
		
		public function Index(){
			$this->mod = "Index";
			if(!$_SESSION['U']['userid']){
				$this->showmessage("您还未登录","?m=Admin/Login" ,2000, "用户登录");
			}else{
				$this->_T['U'] = $_SESSION['U'];
				$this->template();
			}
		}
		
		public function Login(){
			$this->mod = "Login";	
			$this->template();
		}
		
		public function LoginDeal(){
			if($_POST['login']){
				$user = $_POST['name'];
				$userRow = DB::fetch_row("select * from `bb_user` where `username`='{$user}'");
				if(!is_array($userRow)){
					$this->showmessage("用户不存在！","?m=Admin/Login" ,2000, "返回登陆页");
				}
				if(md5(md5($_POST['psw']).$userRow['salt'])==$userRow['password']){
					if($user['per']<=3){
						$_SESSION['U']['userid'] = $userRow['userid'];
						$_SESSION['U']['user']   = $userRow['username'];
						$_SESSION['U']['gender']    = $userRow['gender'];
						$this->showmessage("登陆成功！","?m=Admin/Index" ,2000, "进入后台");
					}else{
						$this->showmessage("权限不足！","?m=Admin/Login" ,2000, "返回登陆页");
					}
				}else{
					$this->showmessage("密码有误！","?m=Admin/Login" ,2000, "返回登陆页");
				}
			}
		}
		
		public function Out(){
			$_SESSION['U'] = null;
			$this->showmessage("安全退出","?m=Admin/Login" ,2000, "返回登陆页");
		}
    }




?>